<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="h" uri="/WEB-INF/config/tag/feonix-tags.tld"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色权限设置</title>
<h:head pagetype="dialog" validity="true" iconfont="true" tree="true"></h:head>
<script>
$(function() {
	var zNodes = ${tree};
	var setting = {
			check: {
				chkStyle:"checkbox",
				chkboxType: { "Y": "ps", "N": "s" },
				enable: true
			}
	};
	$('#tree').tree(setting, zNodes);
});


function submitChecked(){
	var treeObj = $.fn.zTree.getZTreeObj("tree");
	var nodes = treeObj.getCheckedNodes(true);
	var nodeArray = new Array();
	var count = 0;
	for(var i=0; i<nodes.length; i++){
		if(nodes[i].id == 'ALLPARENT'){
			continue;
		}
		nodeArray[count] = nodes[i].id;
		count++;
	}
	var nodeIds = nodeArray.join();
  	ajaxSubmit("modify_submit.do?iid=${iid}&rights=" + nodeIds, {
		success:function(result){
			if(result.success){
				closeDialog(true);
			}else{
				alert(result.message);
			}
		}
	});
}
</script>
</head>
<style>
.rightspan {
	width:120px;  
	float:left; 
	padding:5px 20px;
	overflow:hidden;
	white-space:nowrap;
	text-overflow: ellipsis;
}
</style>
<body>
	<div id="dialog-content" style="padding: 20px 20px 0 20px; overflow: auto;">
		<ul id="tree" class="ztree"></ul>
	</div>
	<div id="dialog-toolbar">
		<div id="dialog-toolbar-panel">
			<input type="button" class="btn btn-primary" value="保存" onclick="submitChecked();"/> 
			<input type="button" class="btn" value="取消" onclick="closeDialog();" />
		</div>
	</div>
</body>
</html>